﻿//
// Copyright (c) 2024 BPer
//

#ifndef SRC_BPERWEBRTC_BPERMEDIADESC_H_
#define SRC_BPERWEBRTC_BPERMEDIADESC_H_
#include <bperutil/buffer/BPerBuffer.h>

#include <bpersdp/BPerSdpType.h>
#include <bpersdp/BPerSSRCInfo.h>
#include <bpersdp/BPerMediaPayloadType.h>

typedef struct
{
	int32_t port;
	BPerSocketProtocol socketProtocol;
    char ip[64];
    char type[32];
}BPerCandidate;

typedef struct{
    char ice_ufrag[32];
    char ice_pwd[128];
    char ice_options[128];
    char fingerprint_algo[128];
    char fingerprint[128];
    char setup[128];
}BPerSessionInfo;

typedef struct{
	int32_t mapid;
	char extmap[128];
}BPerExtmap;

bPer_vector_declare(BPerCandidate)

bPer_vector_declare(BPerExtmap)


typedef struct{
	int32_t port;
	int32_t sctp_port;
	int32_t rtcp_mux;
	int32_t rtcp_rsize;


	int32_t sendonly;
	int32_t recvonly;
	int32_t sendrecv;
	int32_t inactive;

	char type[16];
	char mid[64];
	char msid[64];
	char msid_tracker[64];
	char protos[64];

	BPerSessionInfo session_info;
	BPerMediaPayloadTypeVector payload_types;
	BPerCandidateVector candidates;
	BPerSSRCGroupVector ssrc_groups;
	BPerSSRCInfoVector  ssrc_infos;
	BPerExtmapVector extmaps;
}BPerMediaDesc;

bPer_vector_declare(BPerMediaDesc)

void bPer_create_mediadesc(BPerMediaDesc* desc);
void bPer_destroy_mediadesc(BPerMediaDesc* desc);
int32_t bPer_encode_sessionInfo(BPerSessionInfo* info,BPerBuffer* os);
int32_t bPer_encode_mediadesc(BPerMediaDesc* desc,BPerBuffer* os);
int32_t bPer_mediadesc_update_msid(BPerMediaDesc* desc,char* id);
int32_t bPer_sessioninfo_parse_attribute(BPerSessionInfo* info, char* attribute, char* value);
int32_t bPer_mediadesc_parse_line(BPerMediaDesc* desc,char* line);

#endif /* SRC_BPERWEBRTC_BPERMEDIADESC_H_ */
